package com.lhh.springcommon.entity.vo;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.lhh.springcommon.entity.User;
import com.lhh.springcommon.entity.Video;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * @author 李厚航
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VideoVO {

    private Integer id;

    private String title;

    private String introduction;

    private String cover;

    private String resource;

    private String classification;

    private Integer publisherId;

    private String publisherName;

    private String publisherAvatarUrl;

    private String publisherIntroduction;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    public VideoVO(Video video, User user,LocalDateTime createTime){
        this.id = video.getId();
        this.title = video.getTitle();
        this.introduction = video.getIntroduction();
        this.cover = video.getCover();
        this.resource = video.getResource();
        this.classification = video.getClassification();
        this.publisherId = video.getPublisherId();
        this.publisherName = user.getName();
        this.publisherAvatarUrl = user.getAvatarUrl();
        this.createTime = createTime;
    }
}
